<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>更新热门回收表</title>
</head>
<body>
<form>
    <table border="1">
        <tr><td colspan="2"><h1>更新热门回收表内容</h1></td></tr>
        <tr>
            <td>热门回收ID</td>
            <td>
                    <span id="hotRecycleId_txt"></span><input type="hidden" id="hotRecycleId" name="hotRecycleId"/>
            </td>
        </tr>
        <tr>
            <td>商品ID</td>
            <td>
                    <input type="text" id="productId" name="productId"/>
            </td>
        </tr>
        <tr>
            <td>商品名称</td>
            <td>
                    <input type="text" id="productName" name="productName"/>
            </td>
        </tr>
        <tr>
            <td>平均回收价格</td>
            <td>
                    <input type="text" id="averagePrice" name="averagePrice"/>
            </td>
        </tr>
        <tr>
            <td>回收次数</td>
            <td>
                    <input type="text" id="recycleCount" name="recycleCount"/>
            </td>
        </tr>
        <tr>
            <td>最后修改时间</td>
            <td>
                    <input type="text" id="modifiedTime" name="modifiedTime"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other1" name="other1"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other2" name="other2"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" id="tijiao" value="提交"/>
                <input type="reset" value="重置"/>
            </td>
        </tr>
    </table>
</form>
<script src="/js/jquery-1.12.4.js"></script>
    <script>
    var param = location.href.substring(location.href.indexOf('?')+1);
    $.getJSON("/hotrecycle/findById.json",param,function(detail){
        $("#hotRecycleId_txt").text(detail.hotRecycleId);
        $("#hotRecycleId").val(detail.hotRecycleId);
        $("#productId").val(detail.productId);
        $("#productName").val(detail.productName);
        $("#averagePrice").val(detail.averagePrice);
        $("#recycleCount").val(detail.recycleCount);
        $("#modifiedTime").val(detail.modifiedTime);
        $("#other1").val(detail.other1);
        $("#other2").val(detail.other2);
    });
    //点击提交按钮
    $("#tijiao").click(function(){
        if(!$("#productId").val()){
            alert("商品ID不能为空");
            return;
        }
        if(!$("#productName").val()){
            alert("商品名称不能为空");
            return;
        }
        if(!$("#averagePrice").val()){
            alert("平均回收价格不能为空");
            return;
        }
        if(!$("#recycleCount").val()){
            alert("回收次数不能为空");
            return;
        }
        if(!$("#modifiedTime").val()){
            alert("最后修改时间不能为空");
            return;
        }
        if(!$("#other1").val()){
            alert("其他不能为空");
            return;
        }
        if(!$("#other2").val()){
            alert("其他不能为空");
            return;
        }
        
        $.post("/hotrecycle/update.json",$("form").serialize(),function(result){
            if(result.flag==true){
                alert(result.msg);
                location.href="/admin/hotrecycle/list.html";
            }else{
                alert(result.msg);
            }
        })

    })
</script>

</body>
</html>